home *** CD-ROM | disk | FTP | other *** search
/ L' Effet Pommier 3 / L'Effet Pommier - Volume 03.iso / Education et Sciences / Mathématiques / Matt's_Fract 1.05 / Sources / includes / DialogUtils.c < prev    next >
C/C++ Source or Header  |  1995-11-14  |  2KB  |  102 lines

  1. #include "AllTools.h"
  2.  
  3. Rect GetDRect( DialogPtr dialog, short itemNo )
  4. {
  5. short            iType;
  6. Handle            iHandle;
  7. Rect            iRect;
  8.  
  9. GetDItem( dialog, itemNo, &iType, &iHandle, &iRect);
  10.  
  11. return iRect;
  12. }
  13.  
  14. void SetDRect(DialogPtr dialog, short    itemNo, Rect rect)
  15. {
  16. short            iType;
  17. Handle            iHandle;
  18. Rect            iRect;
  19.  
  20. GetDItem( dialog, itemNo, &iType, &iHandle, &iRect);
  21. SetDItem( dialog, itemNo, iType, iHandle, &rect);
  22. }
  23.  
  24. void SetTheInfoStr(DialogPtr theDialog, short    itemNo, Str255 aValue)
  25. {
  26. short            iType;
  27. Handle            iHandle;
  28. Rect            iRect;
  29.  
  30. GetDItem( theDialog, itemNo, &iType, &iHandle, &iRect);
  31. SetIText(iHandle, aValue);
  32. }
  33.  
  34. void SetTheInfo(DialogPtr theDialog, short    itemNo, long aValue)
  35. {
  36. short            iType;
  37. Handle            iHandle;
  38. Rect            iRect;
  39. Str255            Strng;
  40.  
  41. GetDItem( theDialog, itemNo, &iType, &iHandle, &iRect);
  42. NumToString(aValue, Strng);
  43. SetIText(iHandle, Strng);
  44. }
  45.  
  46. void GetTheInfoStr(DialogPtr theDialog, short itemNo, StringHandle string)
  47. {
  48. short            iType;
  49. Handle            iHandle;
  50. Rect            iRect;
  51.  
  52. GetDItem( theDialog, itemNo, &iType, &iHandle, &iRect);
  53. GetIText(iHandle, *string);
  54. }
  55.  
  56. short GetTheInfo(DialogPtr theDialog, short itemNo)
  57. {
  58. short            iType;
  59. Handle            iHandle;
  60. Rect            iRect;
  61. long            num;
  62. Str255            string;
  63.  
  64. GetDItem( theDialog, itemNo, &iType, &iHandle, &iRect);
  65. GetIText(iHandle, string);
  66. StringToNum(string, &num);
  67.  
  68. return (short)num;
  69. }
  70.  
  71. void CenterDialog(DialogPtr dialog, videoInfo theScreen)
  72. {
  73. Rect    dialogRect;
  74. short    dialogWidth, dialogDepth;
  75.  
  76. dialogRect = ((DialogPeek)dialog)->window.port.portRect;
  77. dialogWidth = dialogRect.left - dialogRect.right;
  78. dialogDepth = dialogRect.top - dialogRect.bottom;
  79.  
  80.     MoveWindow(dialog, ((theScreen.resolutionX + dialogWidth) >> 1), 
  81.                                 ((theScreen.resolutionY + dialogDepth) >> 1), FALSE);
  82. }
  83.  
  84. void ToggleCheckBox(DialogPtr dialog, short item)
  85. {
  86.     short type;
  87.     Handle itemHdl;
  88.     Rect box;
  89.  
  90.     GetDItem(dialog, item, &type, &itemHdl, &box);
  91.     SetCtlValue((ControlHandle)itemHdl, (GetCtlValue((ControlHandle)itemHdl) == 0) ? 1 : 0);
  92. }
  93.  
  94. void SetCheck(DialogPtr dPtr, short ChkItem, short value)
  95. {
  96.     short theType;
  97.     Handle theItem;
  98.     Rect theBox;
  99.  
  100.     GetDItem(dPtr, ChkItem, &theType, &theItem, &theBox);
  101.     SetCtlValue((ControlHandle)theItem, value);
  102. }